

jQuery(function ($) {
    var user = JSON.parse(localStorage.getItem('user_info'));
    if (!user) {
        window.location.href = "/login/login.html";
    }
    var id = user.id;
    //我的收藏
    var storeParam = {
        "[]": {
            "count": 0,
            "GoodsCollect": {
                "user_id": id
            },
            "Goods": {
                "id@": "[]/GoodsCollect/goods_id"
            },
            "GoodsImgs": {
                "goods_id@": "[]/GoodsCollect/goods_id"
            }
        }
    };
    send_ajax('post', '/get', storeParam, function callback(res) {
        var html = "";
        if (res.code == 200) {
            if (res["[]"] != undefined) {
                var data = res["[]"];
                for (var i = 0; i < data.length; i++) {
                    if (data[i].Goods) {
                        html += " <li>\n                        <a target=\"_blank\" href=\"/goods-" + data[i].Goods.id + ".html\" class=\"goods_pic\"><img src=\"" + (data[i].GoodsImgs.thumb ? isImgHttp(data[i].GoodsImgs.thumb) : '/asset/image/tu4.jpg') + "\" alt=" + data[i].Goods.name + "></a>\n                        <p class=\"msg\"><a target=\"_blank\" href=\"/goods-" + data[i].Goods.id + ".html\">" + data[i].Goods.name + "</a></p>\n<p class=\"price\">\uFFE5" + data[i].Goods.goods_price + '/'+data[i].Goods.unit_name+"</p>\n                        </li>";
                    }
                }
                $('#myStore').html(html);
            }
        }
    });
    //推荐字画
    var params = {
        "[]": {
            "count": 4,
            "GoodsRank": {
                "type": 2
            },
            "Goods": {
                "id@": "[]/GoodsRank/goods_id"
            },
            "GoodsImgs": {
                "goods_id@": "[]/Goods/id",
                "main_flag": 1
            }
        }
    };
    $('.same_pic').hide();
    send_ajax('post', '/get', params, function callback(res) {
        var html = "";
        if (res.code == 200&&res["[]"]) {
            var data = res["[]"];
            for (var i = 0; i < data.length; i++) {
                if (data[i].Goods) {
                    html += "  <li>\n<a target=\"_blank\" href=\"/goods-" + data[i].Goods.id + ".html\"><img src=\"" + (data[i].GoodsImgs.thumb ? isImgHttp(data[i].GoodsImgs.thumb) : "") + "\" alt=\"" + (data[i].Goods.name ? data[i].Goods.name : "") + "\"></a>\n <a target=\"_blank\"  href=\"/goods-" + data[i].Goods.id + ".html\"><span class=\"zh\">" + (data[i].Goods.name ? data[i].Goods.name : "") + "</span></a>\n                        <span class=\"last\">\uFFE5" + (data[i].Goods.goods_price ? data[i].Goods.goods_price : "") + "</span>\n                    </li>";
                }
            }
            $('.same_pic .list').html(html);
        }
    });
});